home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1989 Special Issue
/
rerun-1989-special-issue.d64
/
irq source#5
< prev
next >
Wrap
Text File
|
2022-09-20
|
2KB
|
51 lines
;NMI ROUTINE DEMO
;USING TIMERS A & B OF CIA2
;
EXP
LDA #<NEWNMI ;Change RAM NMI Vector
STA $0318
LDA #>NEWNMI
STA $0319
LDA #$FF ;Set up CIA2 registers
STA $DD04 ;Timer A LO
STA $DD05 ;Timer A HI
LDA #$2F
STA $DD06 ;Timer B LO
LDA #$00
STA $DD07 ;Timer B HI
LDA #$51
STA $DD0F ;CRB - Timer B counts Timer A
LDA #$11
STA $DD0E ;CRA - Timer A counts clock cycles
LDA #$82
STA $DD0D ;ICR - Enable Timer B interrupts
RTS
NEWNMI
SEI ;New NMI routine: Set
;interrupt disable
PHA ;Save Registers .A, .X, ,
;and .Y to stack
TXA
PHA
TYA
PHA
LDA $DD0D ;Check ICR to see if interrupt
;is from CIA2
BPL RESTORE ;If not got to KERNAL routine
LDY #$0F ;Rotate direction vectors of the balls
LDX #$0E
LDA $C0D7 ;Save last value to stack
PHA
DLOOP
LDA SD,X ;Push other values up one
STA SD,Y
DEY ;Do next value
DEX
BPL DLOOP ;Check if done
PLA ;Get last value from stack
STA SD ;Put at the beginning
JMP $FEBC ;Jump out through KERNAL NMI exit
RESTORE
JMP $FE4C ;Jump to RESTORE key routine